package com.todofun.business.tuanke.bo;

import java.util.List;

import com.todofun.business.tuanke.vo.Counter;
import com.todofun.common.app.BaseService;

public class CounterService extends BaseService{

	public void addSubscribeUser(Counter counter) {
		saveVo(counter);
	}

	public void editSubscribeUser(Counter counter) {
		updateVo(counter);
	}

	public void delCounter(Long counterId) {
		Counter counter = (Counter)getVoByID(Counter.class,counterId);
		delVo(counter);
	}
	
	public List<Counter> listAllCounter() {
		String hql = "from Counter order by id desc";
		List<Counter> allCounter = queryByHQL(hql);
		return allCounter;
		
	}

	public Counter loadCounter(Long counterId) {
		Counter counter = (Counter)getVoByID(Counter.class, counterId);
		return counter;
	}
	
	//取计数器。默认取主表ID=1的值
	public int getCounter()
	{
		int cnt = 0 ;
		cnt = loadCounter(Long.parseLong("1")).getCounter();
		return cnt;
	}

	//计数器加1.默认去主表ID=1的值
	public void addCounter()
	{
		Counter counter = (Counter)getVoByID(Counter.class, Long.parseLong("1"));
		counter.setCounter(counter.getCounter()+1);
		updateVo(counter);
	}
}
